package com.example.qingyiapp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.qingyiapp.R;
import com.example.qingyiapp.service.entify.Databean;
import com.example.qingyiapp.service.entify.FindFriend;
import com.example.qingyiapp.service.entify.FindTJBean;
import com.example.qingyiapp.service.entify.FriendSquareBean;
import com.example.qingyiapp.service.entify.FriendXxBean;
import com.example.qingyiapp.service.entify.IntrodutioBean;
import com.example.qingyiapp.service.presenter.PersenterMannaer;
import com.example.qingyiapp.service.view.IChildView;
import com.example.qingyiapp.ui.activity.fragment.fragment_AddressUI.address_bean.JavaBean_lv;
import com.example.qingyiapp.ui.activity.fragment.fragment_AddressUI.address_bean.JavaBean_lv2;
import com.example.qingyiapp.ui.activity.fragment.fragment_AddressUI.address_bean.JavaBean_lv3;
import com.example.qingyiapp.ui.activity.fragment.fragment_AddressUI.address_bean.JavaBean_msg;

import java.util.Timer;
import java.util.TimerTask;

public class IntroductionActivity extends AppCompatActivity implements View.OnClickListener, IChildView {

    private TextView Introdution_title;
    private ImageView Introdution_image;
    private Button Introdution_jump;
    private Timer time;
    private String url="http://www.iqingyi.com/";
    private Intent intent;
    private int type=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_introduction);
        initView();
         intent = new Intent(IntroductionActivity.this, MainActivity.class);

        PersenterMannaer persenterMannaer = new PersenterMannaer(IntroductionActivity.this,url);
        persenterMannaer.onCreate();
        persenterMannaer.attchviewa(this);
        persenterMannaer.getIntroduction();
                time = new Timer();
                time.schedule(new TimerTask() {
                    @Override
                    public void run() {
                        if (type==0){
                            startActivity(intent);
                        }else {
                        }

                    }
                },5000);

    }

    private void initView() {
        Introdution_title = (TextView) findViewById(R.id.Introdution_title);
        Introdution_image = (ImageView) findViewById(R.id.Introdution_image);
        Introdution_jump = (Button) findViewById(R.id.Introdution_jump);

        Introdution_jump.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.Introdution_jump:
                type=1;
                startActivity(intent);
                break;
        }
    }

    @Override
    public void onSuccess(Databean s) {

    }

    @Override
    public void onError(String error) {

    }


    @Override
    public void ongetAddress_lvData(JavaBean_lv javaBean_lv) {

    }

    @Override
    public void ongetAddress_lvData2(JavaBean_lv2 javaBean_lv2) {

    }

    @Override
    public void ongetAddress_lvData3(JavaBean_lv3 javaBean_lv3) {

    }

    @Override
    public void ongetAddress_lvData4(JavaBean_msg javaBean_lv4) {

    }

    @Override
    public void ongetfriendSquareBean(FriendSquareBean friendSquareBean) {

    }

    @Override
    public void ongetfindfriend(FindFriend findFriend) {

    }

    @Override
    public void getjsonstring(FindTJBean s) {

    }

    @Override
    public void getfriendxxbean(FriendXxBean friendXxBean) {

    }

    @Override
    public void getIntrodution1(IntrodutioBean introdutioBean) {
        IntrodutioBean.DataBean data = introdutioBean.getData();
        String title = data.getTitle();
        String img = data.getImg();
        Introdution_title.setText(title);
        Glide.with(this).load(img).into(Introdution_image);
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {

    }
}
